package base.regex;


public class Regex {
	
	public static void main(String[] args) {
//		Pattern pattern = Pattern.compile("(<a *href= *\"(.*?)\" *>(.*?)</ *a>)");
//		
//		String string = "test <a  href=  \"1\">2</a> <p> <a href=\"3\">4</a> end1";
//		Matcher matcher = pattern.matcher(string);
//
//		System.out.println("String: " + string);
//		while (matcher.find()) {
//			//System.out.print("Start index: " + matcher.start());
//			//System.out.print(" End index: "  + matcher.end() + " ");
//			System.out.println(matcher.group(1));
//			System.out.println(matcher.group(2));
//			System.out.println(matcher.group(3));
//		}
		
//		{
//		Pattern pattern = Pattern.compile("id=(\\w+)");
//		
//		String string = "<a href=\"http:test.com?id=Url&test1=test2\" >111 11 1111 </a>";
//		Matcher matcher = pattern.matcher(string);
//
//		System.out.println("String: " + string);
//		while (matcher.find()) {
//			//System.out.print("Start index: " + matcher.start());
//			//System.out.print(" End index: "  + matcher.end() + " ");
//			System.out.println(matcher.group(1));
//		}
//		
//		}
		
		String pattern = "^[a-zA-Z0-9-]{1,11}$|^[0-9]{1,12}$";
		
		String string = "";
		if (string.trim().matches(pattern)) {
			System.out.println("FAILED - empty");
		}
		
		string = "-";
		if (! string.trim().matches(pattern)) {
			System.out.println("FAILED - ' -'");
		}
		
		string = "1a";
		if (! string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		string = "1-a";
		if (! string.trim().matches(pattern)) {
			System.out.println("FAILED - ' -'");
		}
		
		string = "a1";
		if (! string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		string = "aaaaaaaaaaa";
		if (! string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		string = "aaaaaaaaaaaa";
		if (string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		
		string = "1";
		if (!string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		string = "111111111111";
		if (!string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		string = "1111111111111";
		if (string.trim().matches(pattern)) {
			System.out.println("FAILED - '" + string + "'");
		}
		
		
		String trimmed = null;
		trimmed = trimmed.trim();
		if (trimmed == null) {
			System.out.println("null");
		}
	}
	
}
